<?php
/**
 * 记一下功能
 * 创建应用（应用入口加配置文件）
 * 创建模块（模块树结构）
 * 创建控制器及创建ACTION
 * 创建单元测试
 */

/**
 * Description of Help
 *
 * @author ananda
 */
class Controller_Controller extends Controller_Console
{
    public $self_name      = 'Controller';
    public $action_list    = array(
        'Index'=>1,
        'Create'=>1,
        'Attach'=>1,
    );

    public $select;

    public function init() {}

    public function checkEnv()
    {
        // 检查是否是在能识别的模块中
        if (Com::glob('env.scan') !== 'MOD') {
            throw new Exception_Console('controller:module_is_not_selected');
        }

        $this->select = Com::glob('env.select');
        if (!$this->select) {
            throw new Exception_Console('controller:module_is_not_selected');
        }
    }

    public function getControllerDir()
    {
        return CROOT.Com::glob('com.dir.module').DIRECTORY_SEPARATOR.
               $this->select.DIRECTORY_SEPARATOR.Com::glob('com.dir.library').DIRECTORY_SEPARATOR.
               'Controller'.DIRECTORY_SEPARATOR;
    }

    public function getActionDir($controller)
    {
        return CROOT.Com::glob('com.dir.module').DIRECTORY_SEPARATOR.
               $this->select.DIRECTORY_SEPARATOR.Com::glob('com.dir.library').DIRECTORY_SEPARATOR.
               'Action'.DIRECTORY_SEPARATOR.$controller.DIRECTORY_SEPARATOR;
    }
}
